package com.lin.linchatgpt.config;

import com.lin.linchatgpt.utils.OpenAiClientUtil;
import com.unfbx.chatgpt.OpenAiClient;
import com.unfbx.chatgpt.OpenAiStreamClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


import java.util.Collections;

/**
 * Copyright(C),2022年-2022,霖霖
 *
 * @author 霖霖
 * @version 1.0
 * @date 2023/4/1 16:14
 * @Description
 */
@Configuration
@Slf4j
public class OpenAIConfig {
    @Value("${apiKey}")
    private  String ApiKey;
    @Bean
    public OpenAiStreamClient getOpenAiStreamClient(){
        return OpenAiClientUtil.getOpenAiStreamClientUtil(Collections.singletonList(ApiKey));
    }

    @Bean
    public OpenAiClient getOpenAiClientUtil(){
        return OpenAiClientUtil.getOpenAiClient(Collections.singletonList(ApiKey));
    }
}
